package org.bozo.im.service.protocols.xmpp.stanza.processor.sasl;

import java.io.IOException;

import org.bozo.im.service.Constants;
import org.bozo.im.service.protocols.xmpp.XMPPSession;
import org.bozo.im.service.protocols.xmpp.stanza.Stanza;
import org.bozo.im.service.protocols.xmpp.stanza.processor.StanzaProcessor;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.util.Log;

public class SuccessStanzaProcessor extends StanzaProcessor {

	private static SuccessStanzaProcessor mInstance;

	private SuccessStanzaProcessor() {}

	public static SuccessStanzaProcessor getInstance() {
		if (mInstance == null)
			mInstance = new SuccessStanzaProcessor();
		return mInstance;
	}

	@Override
	public Stanza getStanza() {
		return Stanza.SASL_SUCCESS;
	}

	@Override
	public void processStanza(XmlPullParser pParser, XMPPSession pSession, StanzaProcessor pParentProcessor) throws XmlPullParserException, IOException {

		if (pParentProcessor == null) {
			// ---------------------------------------------------------------------------------------
			Log.d(Constants.ACTIVITY_TAG, "org.bozo.im.xmpp.stanza.processor.sasl.SuccessStanzaProcessor.processStanza ---------- Authentication successfull, starting new Session");
			// ---------------------------------------------------------------------------------------
			pSession.startSession();

		} else {
			// ---------------------------------------------------------------------------------------
			Log.d(Constants.ACTIVITY_TAG, "org.bozo.im.xmpp.stanza.processor.sasl.SuccessStanzaProcessor.processStanza ---------- I don't know what to do with this Stanza");
			// ---------------------------------------------------------------------------------------
		}
	}
}
